﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Globalization;

namespace WpfApplication2.Validation
{
    public class Required : ValidationRule
    {
        public Required()
        {
        }

        
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (value != null)
            {
                string valor = (String)value;

                if (valor.Length == 0)
                {
                    return new ValidationResult(false, "Este campo es requerido!");
                }
                else
                {
                    return new ValidationResult(true, null);
                }
            }
            return new ValidationResult(false, "Este campo es requerido!");
        }
    }
}
